import router from "../router";
import {default} from "vuex/dist/vuex";


router.beforeEach((to,from,next)=>{
    const hasToken= localStorage.getItem("token")!==''
    console.log("get token to next")
    if (hasToken){
        if (to.path=='/login'){
            next({path:"/admin"}); //放行到/admin
        }else{
            next();// 继续执行接下来的操作
        }
    }else {
        if (to.path=='/login'){
            next();
        }else {
            next({path:"/login"});
        }
    }
})



